home *** CD-ROM | disk | FTP | other *** search
- /*
- File: tracertest.cp
-
- Contains: TTracer is an example of a stack/heap based tracing class, which could be
- used for tracing memory leaks and keeping track of created objects
- TestTracer.cp contains test code for testing the TTracer class.
-
- Written by: Kent Sandvik
-
- Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/18/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- // Include files
- #ifndef _TRACER_
- #include "Tracer.h"
- #endif
- void InvertPermutation(int* perm,
- int* inv,
- int max);
- // Function used for testing TTracer.
- void InvertPermutation(int* perm,
- int* inv,
- int max)
- {
- TTracer autoTracer("InvertPermutation function", TRACEPOINT);
-
- if (perm && (new TTracer("temp", TRACEPOINT))// show TTracer in action
- && inv && (new TTracer("temp2", TRACEPOINT))// these two are never destructed =
- && (max > 0)) // memory leak!
- {
- TTracer otherTracer("otherTracer", TRACEPOINT);
-
- for (int i = 0; i < max; i++)
- {
- TTracer thirdTracer("iterationTracing...", TRACEPOINT);
- inv[perm[i]] = i;
- }
- }
- }
-
-
- // Test code itself.
- void main(void)
- {
- cout << "The TTracer test is starting…\n";
-
- // Array declarations used in the test
- int perm[] = {
- 1, 2, 3, 6, 7};
- int max = 5;
-
- int* inv = new
- int[max];
- InvertPermutation(&perm[0], inv, max);
-
- cout << "The TTracer test ended!\n";
- }
-
- // _________________________________________________________________________________________________________ //
-
-
- /* Change History (most recent last):
- No Init. Date Comment
- 1 khs 7/10/92 New file
- */
-